/** layuiAdmin.std-v1.0.0 LPPL License By http://www.layui.com/admin/ */
;
layui.define(function(e) {
    layui.use(["admin", "carousel"],function() {
        var e = layui.$,
            t = (layui.admin, layui.carousel),
            a = layui.element,
            i = layui.device();
        e(".layadmin-carousel").each(function() {
            var a = e(this);
            t.render({
                elem: this,
                width: "100%",
                arrow: "none",
                interval: a.data("interval"),
                autoplay: a.data("autoplay") === !0,
                trigger: i.ios || i.android ? "click": "hover",
                anim: a.data("anim")
            })
        }),
            a.render("progress")
    }),
        layui.use(["carousel", "echarts"], function() {
            var e = layui.$
                , a = (layui.carousel,
                layui.echarts)
                , t = []
                , n = e("#LAY-index-dataview").children("div")
                , l = function (e) {
                t[e] = a.init(n[e], layui.echartsTheme);
                $.get(ctx+'/userRegionMap', $('form').serialize(), function(result) {
                    if (result.code != 0) {
                        parent.layer.msg(result.msg || '操作失败');
                        return;
                    }
                    t[e].setOption({
                        title: {
                            text: "用户分布图",
                            subtext: "数据每24小时刷新一次"
                        },
                        tooltip: {
                            trigger: "item"
                        },
                        dataRange: {
                            orient: "horizontal",
                            min: 0,
                            max: 55e3,
                            text: ["高", "低"],
                            splitNumber: 0
                        },
                        series: [{
                            name: "用户分布图",
                            type: "map",
                            mapType: "china",
                            mapLocation: {
                                x: "center"
                            },
                            selectedMode: "multiple",
                            itemStyle: {
                                normal: {
                                    label: {
                                        show: !0
                                    }
                                },
                                emphasis: {
                                    label: {
                                        show: !0
                                    }
                                }
                            },
                            data: result.data
                        }]
                    }),
                        window.onresize = t[e].resize
                })
            };
            n[0] && l(0)
        }),
        layui.use(["carousel", "echarts"], function() {
            var e = layui.$
                ,t = layui.carousel
                ,a = layui.echarts
                , i = []
                , n = e("#LAY-index-dataview2").children("div")
                , l = [{
                    title: {
                        text: "最近一周新增的用户量",
                        x: "center",
                        textStyle: {
                            fontSize: 14
                        }
                    },
                    tooltip: {
                        trigger: "axis"
                    },
                    legend: {
                        data: ["", ""]
                    }
                },
                {
                    title: {
                        text: "昨日客户端活跃信息",
                        x: "center",
                        textStyle: {
                            fontSize: 14
                        }
                    },
                    tooltip: {
                        trigger: "item",
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    }
                }],
                n = e("#LAY-index-dataview2").children("div"),
                r = function (e) {
                    i[e] = a.init(n[e], layui.echartsTheme);
                    if(l[e].title.text=="最近一周新增的用户量"){
                        $.get(ctx+'/getWeekRegisterCount', null, function(result) {
                            if (result.code != 0) {
                                parent.layer.msg(result.msg || '操作失败');
                                return;
                            }
                            i[e].setOption({
                                title: {
                                    text: "最近一周新增的用户量",
                                    x: "center",
                                    textStyle: {
                                        fontSize: 14
                                    }
                                },
                                tooltip: {
                                    trigger: "axis"
                                },
                                legend: {
                                    data: ["", ""]
                                },
                                xAxis: [{
                                    type: "category",
                                    boundaryGap: !1,
                                    data: result.data.registerTimes
                                }],
                                yAxis: [{
                                    type: "value"
                                }],
                                series: [{
                                    name: "ANDROID",
                                    type: "line",
                                    smooth: !0,
                                    itemStyle: {
                                        normal: {
                                            areaStyle: {
                                                type: "default"
                                            }
                                        }
                                    },
                                    data: result.data.androidCounts
                                },
                                {
                                    name: "IOS",
                                    type: "line",
                                    smooth: !0,
                                    itemStyle: {
                                        normal: {
                                            areaStyle: {
                                                type: "default"
                                            }
                                        }
                                    },
                                    data: result.data.iosCounts
                                },
                                {
                                    name: "PC",
                                    type: "line",
                                    smooth: !0,
                                    itemStyle: {
                                        normal: {
                                            areaStyle: {
                                                type: "default"
                                            }
                                        }
                                    },
                                    data: result.data.pcCounts
                                },
                                {
                                    name: "云控/web/其他",
                                    type: "line",
                                    smooth: !0,
                                    itemStyle: {
                                        normal: {
                                            areaStyle: {
                                                type: "default"
                                            }
                                        }
                                    },
                                    data: result.data.otherCounts
                                }]
                            });
                        });
                    }else{
                        $.get(ctx+'/getLoginInfoClient', null, function(result) {
                            if (result.code != 0) {
                                parent.layer.msg(result.msg || '操作失败');
                                return;
                            }
                            i[e].setOption(
                            {
                                title: {
                                    text: "昨日客户端活跃信息",
                                        x: "center",
                                        textStyle: {
                                        fontSize: 14
                                    }
                                },
                                tooltip: {
                                    trigger: "item",
                                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                                },
                                legend: {
                                    orient: "vertical",
                                        x: "left",
                                        data: result.data.clientTypes
                                },
                                series: [{
                                    name: "访问来源",
                                    type: "pie",
                                    radius: "55%",
                                    center: ["50%", "50%"],
                                    data: result.data.reports
                                }]
                            });
                        });
                    }
                    window.onresize = i[e].resize;
                };
            if (n[0]) {
                r(0);
                var o = 0;
                t.on("change(LAY-index-dataview2)",
                    function (e) {
                        r(o = e.index)
                    }),
                    layui.admin.on("side",
                        function () {
                            setTimeout(function () {
                                    r(o)
                                },
                                300)
                        }),
                    layui.admin.on("hash(tab)",
                        function () {
                            layui.router().path.join("") || r(o)
                        })
            }
        }),
        e("console", {})
});